<?php
/**
 * Created by PhpStorm.
 * User: Admin
 * Date: 2017-09-22
 * Time: 下午 10:00
 */
error_reporting(E_ALL ^ E_NOTICE);
$content = file_get_contents('wbfull.dat');
$data = unserialize($content);

if(!is_dir('img')) {
    mkdir('img');
}
file_put_contents('download.log', '');
$count = count($data);
echo "\n";
$i = 1;
foreach ($data as $word => $row) {
    $wordEncode = urlencode($word);
    $file = "img/{$wordEncode}.gif";
    
    echo "";
    // $url = "http://www.52wubi.com/wbbmcx/tp/$wordEncode.gif";
    $url = "http://att.chaiwubi.com/wubi/86tj/$wordEncode.gif";
    $log = "$count/$i:".urldecode($url)."\n";
    $i++;
    
    
    if(file_exists($file)) {
        continue;
    }

    echo "$log\n";
    file_put_contents('download.log', urldecode($log), FILE_APPEND);
    
    $imgData = file_get_contents($url);
    file_put_contents($file, $imgData);
}

